package com.hzdl.controller;

import com.hzdl.bean.AssetPlace;
import com.hzdl.bean.Project;
import com.hzdl.service.AssetPlaceService;
import com.hzdl.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;

/**
 * author:Administrator
 * date:2018\9\10 0010
 * description:
 */
@Controller
@RequestMapping("/assetPlace")
public class AssetPlaceController {
    @Autowired
    private AssetPlaceService assetPlaceService;
    @Autowired
    private ProjectService projectService;
    @RequestMapping("/getAllAp")
    public String getAllProjectsByC(Model model){
        List<AssetPlace> assetPlaces = assetPlaceService.getAllAp();

        HashMap<AssetPlace,List<Project>> APMap = new HashMap<>();

        for (AssetPlace assetPlace:assetPlaces) {
            int comp= assetPlace.getId();
            List<Project> ps= projectService.getAllProjectsByC(comp);
            APMap.put(assetPlace,ps);

        }
        model.addAttribute("APMap",APMap);
        System.err.println(APMap);
        return "company";
    }
}
